<?php
/**
 *Create by PhpStorm
 *User:Kendy
 *Date:2019/10/11/011
 *Time:16:06
 */
namespace app\admin\model;
use think\Controller;
use think\Model;
use think\Db;
use app\common\model\UserModel as um;
class OrderComplains extends Model{

    protected $name = 'order_complains';
    /**
     * 根据搜索条件获取所有的投诉订单数据
     * @param $where  查询条件
     * @param $offset
     * @param $limit
     * @return mixed
     */
    public function getComplainList($where,$offset, $limit)
    {
            $rdata= $this
            ->alias('oc')
            ->join('user u','oc.u_id=u.uid','left')
            ->where($where)
            ->field('oc.complain_id,oc.object_name,oc.order_sn,oc.u_id,oc.order_type,oc.complain_status,oc.complain_annex,oc.complain_content,oc.create_time,oc.object_name,oc.object_type,u.nickname')
            ->order('complain_id desc')
            ->limit($offset, $limit)
            ->select();
            if(count($rdata)>0)
            {
                foreach ($rdata as $k => $v) {
                    $rdata[$k]['complain_status'] = lvOrderComplainstatus($v['complain_status']);
                }
            }
            return $rdata;
    }

    /**
     * 根据搜索条件获取所有的投诉订单数量
     * @param $where  查询条件
     * @return mixed
     */
    public function  getComplainCount($where)
    {
        return $this
            ->alias('oc')
            ->join('user u','oc.u_id=u.uid','left')
            ->where($where)
            ->count();
    }
}